package Dao.Impl;

import Dao.Dao;
import bean.Emp;
import util.BaseDao;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class DaoImpl implements Dao {

    @Override
    public Emp login(String name) {
        Emp emp = null;
        String sql = "SELECT * FROM f_shop where name = ?";
        PreparedStatement ps = BaseDao.getPs(sql);
        try {
            ps.setString(1,name);
            ResultSet rs = ps.executeQuery();
            while (rs.next()){
                int id = rs.getInt(1);
                String userName = rs.getString(2);
                String passWord = rs.getString(3);

                emp = new Emp(id,userName,passWord);
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return emp;
    }
}
